<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description" content="Creative - Bootstrap 3 Responsive Admin Template">
	<meta name="author" content="GeeksLabs">
	<meta name="keyword" content="Creative, Dashboard, Admin, Template, Theme, Bootstrap, Responsive, Retina, Minimal">
	<link rel="shortcut icon" href="img/favicon.png">
</head>
<body>
<form id="inputForm">
<div class="modal-header">
	<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
	<h4 class="modal-title">账号设置</h4>
</div>
<div class="modal-body">
	<section class="content">
		<div class="panel panel-default" style="padding-bottom: 10px;">
			<div class="row data-type" style="margin: 10px 5px;border: 1px solid #d4d4d4;border-radius: 2px;">
				<div class="col-md-2 title">用户名</div>
				<div class="col-md-10 data text">
					#(admin.username)
				</div>
				<div class="col-md-2 title">姓名</div>
				<div class="col-md-10 data text">
					#(admin.name)
				</div>
				<div class="col-md-2 title">当前密码</div>
                <div class="col-md-10 data">
                    <input type="password" class="form-control" placeholder="当前密码" id="currentPassword" name="currentPassword" value="">
                </div>
                <div class="col-md-2 title">新密码</div>
                <div class="col-md-10 data">
                    <input type="password" class="form-control" placeholder="新密码" name="password" id="password" value="">
                </div>
                <div class="col-md-2 title">确认新密码</div>
                <div class="col-md-10 data">
                    <input type="password" class="form-control" placeholder="确认新密码" name="rePassword" value="">
                </div>
			</div>
		</div>
	</section>
</div>
<div class="modal-footer">
	<button type="button" class="btn " data-dismiss="modal">关闭</button>
	<button type="submit" class="btn btn-primary">保存</button>
</div>
</form>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");
	
	// 表单验证
	$inputForm.validate({
		rules: {
			currentPassword: "required",
			password: {
				minlength: 4
			},
			rePassword: {
				equalTo: "#password"
			}
		},
		submitHandler: function(form) {
			$.ajax({
				url: "#(base)/admin/profile/update",
				type: "POST",
				data: $(form).serialize(),
				dataType: "json",
				cache: false,
				success: function(response) {
					if (response.type=="success") {
						swal({title:'', text:'操作成功',icon: 'success',button:false,timer: 2000}).then(function(){
							$(".close").trigger("click");
						});
					}else{
						swal({title:'', text:response.msg,icon: 'error'});
					}
				}
			});
			return false;
		}
	});

});
</script>